/* eslint-disable no-new */
var fs = require('fs');
//组件映射
var wx2acCompMap = {'view': 'ac-view',
                'button': 'ac-button',
                'navigator': 'ac-navigator'
                };
//指令映射
var wx2acDireMap = {'wx:if': 'ac:if'};

exports.getContent = function(srcPath){
    var data = fs.readFileSync(srcPath+'.wxml', 'utf-8', function (err, bytesRead) {
        if (err) throw err;
    });
    for(var key in wx2acCompMap){
        console.log(key + ' convert 2 '+ wx2acCompMap[key])
        data = data.replace(new RegExp("<"+key+" ", "g"), '<'+wx2acCompMap[key]+' ')
        .replace(new RegExp("<\/"+key+">", "g") , '</'+wx2acCompMap[key]+'>')
        .replace(new RegExp( "<"+key+">", "g"), '<'+wx2acCompMap[key]+'>')
    }
    for(var key in wx2acDireMap){
        console.log(key + ' convert 2 '+ wx2acDireMap[key])
        data = data.replace(new RegExp( ""+key+"", "g"), ''+wx2acDireMap[key]+'')
    }
    return data;
}